﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL.Dao
{
    public enum ExecuteType
    {
        Add,
        Delete,
        Update,
    }
    public class BaseDao
    {
        protected readonly object clock_obj_add;
        protected readonly object clock_obj_update;
        protected readonly object clock_obj_delete;
        protected readonly bool use_clock;
        public BaseDao(bool use_clock)
        {
            clock_obj_add = new object();
            clock_obj_update = new object();
            clock_obj_delete =  new object();
            this.use_clock = use_clock;
        }

        public static int GetTotalPages(int total_count, int rows)
        {

            int totalPages = 0;
            if (total_count % rows == 0)
            {
                totalPages = total_count / rows;
            }
            else totalPages = total_count / rows + 1;
            return totalPages;
        }
        public virtual bool ExecuteAdd()
        {
            throw new NotImplementedException();
        }
        public virtual bool ExecuteDelete()
        {
            throw new NotImplementedException();
        }
        public virtual bool ExecuteUpdate()
        {
            throw new NotImplementedException();
        }
        //public void Execute<T>(T obj,  Action<T> action, ExecuteType executeType)
        //{
        //    switch (executeType)
        //    {
        //        case ExecuteType.Add:
        //            lock (clock_obj_add)
        //            {
        //                action.Invoke(obj);
        //            }
        //            break;
        //        case ExecuteType.Delete:
        //            lock (clock_obj_delete)
        //            {
        //                action.Invoke(obj);
        //            }
        //            break;
        //        case ExecuteType.Update:
        //            lock (clock_obj_update)
        //            {
        //                action.Invoke(obj);
        //            }
        //            break;
        //        default:
        //            break;
        //    }
        //}
    }
}
